<?php

class Application_Model_Names extends Zend_Db_Table_Abstract
{

protected $_name = 'family_names';

    public function getUser($id) {
        $id = (int) $id;
        $row = $this->fetchRow('person_id = ' . $id);
        if (!$row) {
            throw new Exception("Could not find row $id");
        }
        return $row->toArray();
    }

    public function addUser($type, $title, $forenames, $link, $surname, $suffix, $knownas) {
        $data = array(
            'type' => $type, 
            'title' => $title, 
            'forenames' => $forenames, 
            'link' => $link, 
            'surname' => $surname, 
            'suffix' => $suffix, 
            'knowas' => $knowas
        );
        $this->insert($data);
    }

    public function updateUser($person_id, $type, $title, $forenames, $link, $surname, $suffix, $knownas) {
        $data = array(
            'type' => $type, 
            'title' => $title, 
            'forenames' => $forenames, 
            'link' => $link, 
            'surname' => $surname, 
            'suffix' => $suffix, 
            'knowas' => $knowas,
        );
        $this->update($data, 'person_id = '. (int) $person_id);
    }



    public function deleteUser($id) {
        $this->delete('person_id =' . (int) $id);
    }
}

